# 8. 最长的指定瑕疵度的元音子串
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.on('line', (input) => {
let flaw = parseInt(input);
rl.on('line', (input) => {
let aeiou = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'];
let indexArr = [];
for(let i=0; i<input.length; i++) {
if (aeiou.includes(input[i])) {
indexArr.push(i);
}
}
let left = 0;
let right = 0;
let ans = [];
while(right < indexArr.length) {
let curFlaw = indexArr[right] - indexArr[left] - (right - left);
if (curFlaw > flaw) {
left++;
} else {
if (curFlaw === flaw) {
ans.push(indexArr[right] - indexArr[left] + 1);
}
right++;
}
}
console.log(Math.max(ans));
});
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
← 7. 查找众数及中位数 9. 整数对最小和 →